# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=k0sctl
pkgver=0.16.0
pkgrel=1
pkgdesc="Bootstrapping and management tool for k0s clusters"
url="https://github.com/k0sproject/k0sctl"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/k0sproject/k0sctl/archive/refs/tags/v$pkgver/k0sctl-$pkgver.tar.gz"
options="chmod-clean"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make TAG_NAME="v$pkgver" GIT_COMMIT=""

	for shell in bash fish zsh; do
		./$pkgname completion --shell $shell >$pkgname.$shell
	done
}

check() {
	make test
}

package() {
	make PREFIX=/usr DESTDIR="$pkgdir" install

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
66b3dbabc9c6cefd0d54d0d71b27f1a5e8b4597fdf61f389bde73402a376a671c0481458f688600109c544e589cbcfdad347049dbd0150f000b481769617e644  k0sctl-0.16.0.tar.gz
"
